<template>
	<view class="setting">
		<view class="app-logo">
			<image src="../../static/img/indexImg/applogo.png" mode="aspectFill" class='logo-icon'></image>
			<view class="app-tit">{{appName}}</view>
		</view>
		<view class="wrapper">
			<view class="item" hover-class="none" @click="agreementLang">
				<text>{{i18n.protocol}}</text>
				<view>
					<text class="iconfont">&#xe600;</text>
				</view>
			</view>
			<view class="item" @click="handleUpdate">
				<text>{{i18n.update}}</text>
				<view>
					<text class="active">V{{version}}</text>
					<text class="iconfont">&#xe600;</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import UpdateVersion from '@/utils/update.js';
import {version ,appName, defaultLanguage ,domain} from '@/config.js'

export default {
	data() {
		return {
			appName,
			version,
			title:''
		};
	},
	onShow(){
		uni.setNavigationBarTitle({
		 title: this.$t('about.about')
		})
	},
	computed:{
		i18n() {
			return this.$t('about');
		}
	},
	methods: {
		handleUpdate() {
			//#ifdef APP-PLUS
			var v = new UpdateVersion();
			v.getNewData('1');
			//#endif
			//#ifdef H5
			this.$toast('当前环境暂不支持更新');
			//#endif
		},
        agreementLang(){
			 this.lang = uni.getStorageSync('lang') || defaultLanguage
			 let domain_name = uni.getStorageSync('available_domain') || domain
			 // #ifdef APP-PLUS
					if(this.lang == 'zh-cn'){
					   plus.runtime.openWeb(domain_name+'agreement_cn.html')
					}else if(this.lang == 'en-us'){
						plus.runtime.openWeb(domain_name+'agreement_en.html')
					}
			 // #endif
			  //#ifdef H5
					if(this.lang == 'zh-cn'){
						window.open(domain_name+'agreement_cn.html')
					}else if(this.lang == 'en-us'){
						window.open(domain_name+'agreement_en.html')
					}
			  //#endif
        }
	}
};
</script>

<style lang="less" scoped>
	.wrapper{
		font-size: 28upx;
	}

.setting {
	overflow: hidden;

	.modal-body {
		height: 300upx;
		background-color: #fff;
		position: absolute;
		bottom: 0;
		left: 0;
		right: 0;
		border-radius: 20upx 20upx 0upx 0upx;
		text-align: center;
		view {
			line-height: 100upx;
			border-bottom: 1px solid var(--border);
			&:nth-last-child(1) {
				border: none;
			}
			&.cancel {
				color: #9dacb9;
			}
		}
	}
	
    .wrapper {
    	margin: 0 30upx;
    
    	.item {
    		display: flex;
    		justify-content: space-between;
    		line-height: 100upx;
            color:var(--txt-color);
			border-bottom: 1upx solid var(--border);
    		.active{
    			color: var(--theme-color);
    		}
    
    		.iconfont {
    			margin-left: 20upx;
    			font-size: 24upx;
    		}
    	}
    }
}

</style>
